/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vue;

import ia_multiagent1.Agent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
import utilityIA.Utile;

/**
 *
 * @author Baptiste
 */
public class JPanelHistogramme extends JPanel {
    
    private int hauteurFenetre;
    private int largeurFenetre;
    
    private int r1;
    private int r2;
    private int r3;
    
    
    public JPanelHistogramme(int r1, int r2, int r3){
        this.hauteurFenetre = 400;
        this.largeurFenetre = 250;
        this.r1 = r1;
        this.r2 = r2;
        this.r3 = r3;
    }
    
    @Override
    public void paint(Graphics g){
        Graphics2D g2d = (Graphics2D) g;
        
        // axes
        g2d.setColor(Color.BLACK);
        g2d.drawLine(40, 40, 40, 360);
        g2d.drawLine(40, 360, 200, 360);
        
        g2d.drawLine(40, 40, 35, 45);
        g2d.drawLine(40, 40, 45, 45);
        g2d.drawLine(200, 360, 195, 355);
        g2d.drawLine(200, 360, 195, 365);
        
        int max = Utile.max(r1, r2, r3);
        
        int h1 = 0;
        int h2 = 0;
        int h3 = 0;
        
        if (max != 0){
            h1 = 260*r1/max;
            h2 = 260*r2/max;
            h3 = 260*r3/max;
        }
        
        g2d.drawLine(36, 100, 44, 100);
        
        //Centré sur 80
        g2d.setColor(Color.RED);
        g2d.fillRect(70, 360-h1, 20, h1);
        g2d.drawString("R1", 70, 375);
        
        
        g2d.setColor(Color.BLACK);
        g2d.drawLine(36, 360-h1, 44, 360-h1);
        g2d.drawString(Integer.toString(r1), 4, 360-h1);
        
        //Centré sur 120
        g2d.setColor(Color.BLUE);
        g2d.fillRect(110, 360-h2, 20, h2);
        g2d.drawString("R2", 110, 375);
        
        g2d.setColor(Color.BLACK);
        g2d.drawLine(36, 360-h2, 44, 360-h2);
        g2d.drawString(Integer.toString(r2), 4, 360-h2);
        
        //Centré sur 160
        g2d.setColor(Color.YELLOW);
        g2d.fillRect(150, 360-h3, 20, h3);
        g2d.drawString("R3", 150, 375);
        
        g2d.setColor(Color.BLACK);
        g2d.drawLine(36, 360-h3, 44, 360-h3);
        g2d.drawString(Integer.toString(r3), 4, 360-h3);
        
    }
    
    
    

}
